% Get table of an index including index code, date, and close index
% Input: index_code
% Output: index_code, date, close_index
function [index_code date closed_index volume] = getIndex(index_code)

    % the query is used to access the database to get table of the index index_code
    query = strcat('select t.Date, s.Name, t.ClosePrice, t.Volume from security s, transaction t where s.ID = t.ID_Security and s.Name =', '''', index_code, ''';');
    % get the output table after using the query to access the database
    output_table = selectData(query);

    if (~isempty(output_table)) % the market index is exists => get data from output_table
        date = cell2mat(output_table(:, 1));
        date = datenum(date);
        closed_index = cell2mat(output_table(:, 3));
        volume = cell2mat(output_table(:, 4));
    else % the market index is not exists => set data null
        index_code = [];
        date = [];
        closed_index = [];
        volume = [];
    end
end